<?php

function RedirectTo($toUrl,$type='header') {
	if ( $type == 'meta' ) {
		'<meta http-equiv="Refresh" content="0; URL='.$toUrl.'">';
	} elseif ($type == 'script' ) {
		echo '<script type="text/javascript">window.location="'.$toUrl.'"</script>';
	} else {
		header('Location: '.$toUrl);
	}
}

function antiLeech($t_id) {
	global $CURUSER, $options;
	if ( !empty($options['use_antileech']) ) {
		if ( (($CURUSER['uploaded']/$CURUSER['downloaded']) > $options['min_rate']) ) {
			$q='select count(*),owner from snatched INNER JOIN torrents ON torrents.id=snatched.torrent WHERE userid= '.$CURUSER['id'].' AND finished = \'yes\' and torrent = ' . sqlesc($t_id);
			$r=sql_query($q) or sqlerr(__FILE__,__LINE__);
			$data=mysql_fetch_array($r);
			if ( $r[0] && ($r[1] != $CURUSER['id']) ) return true;
		}
	}
	return false;
}

function ShowInformationMessage() {
	if ( !empty($_COOKIE['infomsg']) ) {
		$data=unserialize($_COOKIE['infomsg']);
		stdmsg($data['title'],$data['text'],$data['type']);
		unset($data);
		setcookie('infomsg','');
	}
}

?>